package com.qf.controller;

import com.qf.entity.OrderDetail;
import com.qf.entity.User;
import com.qf.service.OrderDetailService;
import com.qf.service.impl.OrderDetailServiceImpl;
import com.qf.utils.StringUtils;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 10202
 * @version V1.0
 * @Project xiaomi
 * @Package com.qf.controller
 * @Date 2023/4/15 15:58
 */
@WebServlet(urlPatterns = "/getOrderDetail")
public class GetOrderDetail extends  BaseServlet{
    public String getOrderDetail(HttpServletRequest request, HttpServletResponse response){
        User user = (User) request.getSession().getAttribute("user");
        if(user==null){
            return "redirect:/login.jsp";
        }
        String oid = request.getParameter("oid");
        if(StringUtils.isEmpty(oid)){
            request.setAttribute("msg","订单有问题");
            return "/message.jsp";
        }
        OrderDetailService orderDetailService=new OrderDetailServiceImpl();
        try {
            OrderDetail od=orderDetailService.queryOrderDetail(oid);

            request.setAttribute("od",od);
            return "/orderDetail.jsp";
        } catch (Exception e) {
            e.printStackTrace();
            request.setAttribute("msg","订单详细界面有误");
            return "/message.jsp";
        }

    }


}
